set the visible of card field 1 to not the visible of card field 1
if the visible of card field 1 is true then
set the name of me to "Hide LSP Source"
else set the name of me to "Show LSP Source"
end mouseUp
-- part contents for background part 16
----- text -----
PRINTFIELD XCMD version 1.4.1
Kevin Calhoun
NOTE TO USERS OF EARLIER VERSIONS: The parameter list has changed in PrintField 1.4. Please be sure to read "NEW IN VERSION 1.4" if you would like to replace earlier versions with version 1.4 in your stacks.
The PrintField XCMD allows you to print the text of a field in the field's current textFont, textSize, textStyle, textHeight, and width. You may supply additional information about margins in order to place the text anywhere you like on the page.
PrintField uses a dialog box to inform the user that printing is in progress. It passes to the printer driver the short name of the field to be printed as the document name.
In case of an error, PrintField returns an error message as the Result. Word 1 of this message will be "Error."
PrintField can print only one field at a time. It works with both the LaserWriter and the ImageWriter.
NEW IN VERSION 1.4:
The parameter list has changed in order to accommodate users who wanted the option of skipping the Page Setup and Print Job dialog boxes. A new parameter has been added after the field designation and before the margin settings, called dialogCount, which determines which of the print dialog boxes the user sees. If you used margin settings with earlier versions of PrintField, you will have to alter your scripts to accord with the new parameter list used by version 1.4.
Parameters given inside the brackets, such as <notNeeded>, are optional.
fieldDesignation:
You may designate the field to print in any way considered valid by HyperCard, by number, id, or name, with one exception: you can't use the field's name if it is more than one word. If you do use the field's name, don't put the field name in quotation marks. Nested quotations confuse HyperCard. (See the examples below.)
dialogCount:
If dialogCount is 2 (or anything other than 0 or 1), then the user will see both the Page Setup and the Print Job dialog boxes before the printing process begins. If dialogCount is 1, then the user will see only the Print Job dialog box. If dialogCount is 0, then neither of these dialog boxes will appear before printing. If you set dialogCount equal to 0 or 1, thereby supressing one or both of the print dialogs, then the default settings stored in the printer resource file will be used for the print job, just as if the user clicked "OK" without changing any of the settings in the dialog.
There is no way in this version to set such things as paper orientation or number of copies to values other than the defaults by any means other than the dialog boxes. Moreover, PrintField is unable to access the settings the user designates by choosing Page Setup from HyperCard's File menu. If you want to enable printing with settings other than the defaults, set dialogCount to 2.
Setting Margins:
Values for leftMargin, rightMargin, topMargin, and bottomMargin are given in pixels. According to QuickDraw, one pixel equals 1/72 inch; therefore you can specify a one inch margin by passing 72 as the margin parameter. If you don't supply margin parameters, PrintField defaults to half-inch margins on the top, left, and bottom of the page, and prints each line of the text about as wide as it appears on the screen.
Valid Examples--
1. PrintField "bkgnd field 1" -- default values will be used for margins
2. PrintField "bkgnd field 1",0,0,0,0,0 -- this will print as much as possible on a page
3. PrintField "card field id 22",2,72,72,72,72 -- by id, with one inch margins all around
4. PrintField "card field foo",2,72 -- by name, with a left margin one inch wide
See the script of the button "Print the Documentation" for another example.
It is possible to put the designation of the field into a variable and then pass the variable to PrintField, as follows…
on openField
if the optionKey is down then
put the name of the target into theName
put the id of the target into theField
if word 1 of theName is "card" then put "card field id " before theField
else put "field id " before theField
PrintField theField
end if
end openField
This handler prints a field if the field is clicked while the option key is down.
COPYING PRINTFIELD INTO YOUR STACKS
Warning to ResEdit and ResCopy users: PrintField requires a DLOG resource and a DITL resource as well as the XCMD resource--these resources are named "PrintField" and numbered 9140 (the same number as the PrintField XCMD) so you can find them easily. If either the DITL or the DLOG resource is not present, PrintField will still print properly, and printing can still be cancelled by pressing command-period, but the user won't have the benefit of the information the dialog provides.
CHANGE HISTORY
3/7/88 1.0
3/17/88 1.1 -- Fixed erasure problem when printing on LaserWriter with a small lineHeight.
4/7/88 1.2 -- Dialog now centered on third party screens also.
6/8/88 1.4 -- Fixed problem printing multiple pages on ImageWriter. Improved error handling to accord with changes in HyperCard 1.2. Added option of skipping one or both print dialogs. Improved WYSIWYG default margins (the width of the line on the page is much more often the same as it appears on the screen). Fixed problem with last line of page when font ascent was small.
NOTES FOR PROGRAMMERS:
PrintField contains code for finding out about all the properties of a field. You might find the functions GetFontOfField, GetJustOfField, etc., to be useful in your XCMD's.